package com.orhon.smartcampus.modules.base.fetcher;

import com.orhon.smartcampus.modules.base.dao.SchoolTypeDao;
import com.orhon.smartcampus.modules.base.entity.SchooltypesDeleateable;
import com.orhon.smartcampus.modules.base.gqlModel.GQLSchoolType;
import com.orhon.smartcampus.modules.base.mm.SchoolTypeMapper;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class SchoolTypeFetcher implements DataFetcher {

	@Autowired
	private SchoolTypeDao schoolTypeDao;

	@Override
	public Object get(DataFetchingEnvironment env) throws Exception {
		int id = Integer.parseInt(env.getArgument("id").toString());
		String hql = "from SchooltypesDeleateable where deleted_at = null and id = "+id;
		SchooltypesDeleateable item = schoolTypeDao.findId(hql, null);

		GQLSchoolType gqlSchoolType = SchoolTypeMapper.MAPPER.fromEntity(item);
		return gqlSchoolType;
	}


}
